package com.boot.utils;

import com.boot.myannotation.ExportFieldAnnotation;
import org.apache.commons.lang3.StringUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Chunsheng.Zhang
 * @date 2021/2/1 17:21
 * @description : TODO
 */
public class MyClassHandler {

    public static String getAnnotationFiled(Field[] fAll){
        List titles = new ArrayList<>();
        for(int i=0;i<fAll.length;i++){
            //获取该字段所有的注解
            Annotation[] annotations = fAll[i].getDeclaredAnnotations();
            for(Annotation annotation : annotations){
                //只获取指定注解的字段
                if(annotation instanceof ExportFieldAnnotation){
                    titles.add(fAll[i].getName());
                }
            }
        }
        String s = StringUtils.join(titles,",");
        System.out.println("export titles : ");
        return s;
    }
}
